package com.itheima.chapter01.array;
/*
    数组反转（数值交换）
 */
public class demo6 {
    public static void main(String[] args) {
        int[] arr={19,28,37,45,50,66,78,89};
        int start=0;
        int end=arr.length-1;//减1为了数组最后一位
        for (; start <end ; start++,end--) {
            int temp=arr[start];
            arr[start]=arr[end];
            arr[end]=temp;
        }
        for (int i = 0; i <arr.length ; i++) {
            System.out.println(arr[i]);
        }
        System.out.println("-----------------------------");
        System.out.println("数值交换");
        int a=10;
        int b=20;
        int temp=a;
        a=b;
        b=temp;
        System.out.println("a="+a);
        System.out.println("b="+b);
        System.out.println("........");
        int aa=10;
        int bb=20;
        aa=aa^bb;
        bb=aa^bb;
        aa=aa^bb;
        System.out.println("aa="+aa);
        System.out.println("bb="+bb);
    }
}
